package iso3.pt.action;

import iso3.pt.model.Alumno;
import iso3.pt.model.Asignatura;
import iso3.pt.service.PtDaoService;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

public class SubjectMarkingAction extends ActionSupport implements Preparable
{
	private static final long serialVersionUID = 1L;
	private Alumno alumno;
	private Asignatura asignatura;
	private int subjectID;
	private int studentDNI;
	private String concept;
	private float mark;
	
//get y sets-------------------------------------------------------
	
	public String getConcept() {
		return concept;
	}

	public void setConcept(String concept) {
		this.concept = concept;
	}

	public float getMark() {
		return mark;
	}

	public void setMark(float mark) {
		this.mark = mark;
	}

	public Alumno getAlumno() {
		return alumno;
	}

	public void setAlumno(Alumno alumno) {
		this.alumno = alumno;
	}

	public Asignatura getAsignatura() {
		return asignatura;
	}

	public void setAsignatura(Asignatura asignatura) {
		this.asignatura = asignatura;
	}

	public int getSubjectID() {
		return subjectID;
	}

	public void setSubjectID(int subjectID) {
		this.subjectID = subjectID;
	}

	public int getStudentDNI() {
		return studentDNI;
	}

	public void setStudentDNI(int studentDNI) {
		this.studentDNI = studentDNI;
	}

//FIN get y sets-------------------------------------------------------
	
	public void prepare() throws Exception 
	{
		PtDaoService hibernateDAO = new PtDaoService();
		
		this.alumno = hibernateDAO.getAlumno(studentDNI);
		this.asignatura = hibernateDAO.getAsignatura(subjectID);
		
	}
	
//do's-------------------------------------------------------
	
	public String doMakeMarkForm()
	{
		return SUCCESS;
	}

	public String doSubmitMark()
	{
		PtDaoService hibernateDAO = new PtDaoService();
		hibernateDAO.addEvaluacion(this.concept, this.mark, this.subjectID, this.studentDNI);
		
		return "showStudentSubjectMarks";
	}
	
//FIN do's-------------------------------------------------------
	
}
